Skip to content

Respect explicit filenames when uploading filesystem paths - #487

Open
Twiink wants to merge 1 commit into
replicate:mainfrom
Twiink:codex/20261128-explicit-upload-filename
Open

Twiink wants to merge 1 commit into
replicate:mainfrom
Twiink:codex/20261128-explicit-upload-filename

Conversation

@Twiink

@Twiink Twiink commented Nov 28, 2026

Copy link
Copy Markdown

Passing a filesystem path to client.files.create(..., filename="image.png") silently replaces the requested filename with the path's basename. For a temporary .bin path this also makes the upload use application/octet-stream instead of image/png. The asynchronous API has the same behavior.

Use the path basename only when no filename was supplied. Add four request-level regression cases covering string/Path inputs and synchronous/asynchronous uploads, checking the multipart filename, inferred content type and file bytes.

Validation on Python 3.12:

  • All four new cases fail against the original implementation and pass with the fix.
  • ./script/test: 162 passed, 6 skipped (the existing live API tests require credentials).
  • ./script/lint: passed, including Pyright, Ruff lint and formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant